package com.spzx.channel.service.impl;

import com.spzx.channel.service.ICategoryService;
import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.domain.R;
import com.spzx.product.api.RemoteCategoryService;
import com.spzx.product.api.domain.vo.CategoryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: CategoryServiceImpl
 * Package: com.spzx.channel.service.impl
 * Description:
 *
 * @Author 咚咚小圆帽
 * @Create 2025/3/16 20:40
 * @Version 1.0
 */
@Service
@Slf4j
public class CategoryServiceImpl implements ICategoryService {

    @Autowired
    private RemoteCategoryService remoteCategoryService;

    @Override
    public List<CategoryVo> tree() {
        R<List<CategoryVo>> treeResult = remoteCategoryService.tree(SecurityConstants.INNER);
        //判断是否抛出异常
        if (R.FAIL == treeResult.getCode()) {
            //降级处理
            log.error(treeResult.getMsg());
        }
        return treeResult.getData();
    }
}
